package com.lysh.http.api;

import com.lysh.http.enums.ErrorMessage;
import com.lysh.http.exception.SDKException;
import com.lysh.http.utils.CheckUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liyishan
 * @date 2023/4/19 12:48
 */

public abstract class AbstractAPI implements API {
    protected ApiParams apiParams;
    protected Map<String, String> headers = new HashMap();

    public AbstractAPI() {
        this.headers.put("Content-Type", "multipart/form-data");
    }

    public ApiParams getAPIParams() {
        return this.apiParams;
    }

    public void setAPIParams(ApiParams apiParams) {
        this.apiParams = apiParams;
    }

    public Map<String, String> getHeaders() {
        return this.headers;
    }

    public void addHeader(String headerName, String headerValue) throws SDKException {
        CheckUtils.checkArgument(StringUtils.isNotBlank(headerName), ErrorMessage.PARAM_ERROR, "headerName can not be null!");
        CheckUtils.checkArgument(StringUtils.isNotBlank(headerValue), ErrorMessage.PARAM_ERROR, "headerValue can not be null!");
        this.headers.put(headerName, headerValue);
    }

    public String getVersion() {
        return "v1";
    }

    public boolean hasFile() {
        return false;
    }

    public boolean hasDownload() {
        return false;
    }
}

